<ResourceDictionary	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf"
                    xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
                    xmlns:gui="clr-namespace:DentalGUIHelper;assembly=DentalConfig"
                    xmlns:System="clr-namespace:System;assembly=mscorlib">

    <gui:ObjectToFrameworkElementConverter x:Key="FrameworkElementConverter"/>

    <!-- This Style will make a ListBoxItem look like a Metro-Tile (Windows 8) -->
    <Style x:Key="TileListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{DynamicResource SecondaryAccentBrush}"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}, FallbackValue=Stretch}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}, FallbackValue=Center}"/>
        <Setter Property="Margin" Value="4"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="wpf:ShadowAssist.ShadowDepth" Value="Depth1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                  <Grid Margin="{TemplateBinding Margin}">
                    <Border x:Name="shadowBorder" CornerRadius="2" Background="{DynamicResource MaterialDesignPaper}" wpf:ShadowAssist.ShadowDepth="{TemplateBinding wpf:ShadowAssist.ShadowDepth}" Effect="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}"/>
                    <Grid Background="{TemplateBinding Background}" x:Name="itemOuterGrid">
                        <Grid.OpacityMask>
                          <VisualBrush gui:TileBrushHelper.ViewportSizeSource="{Binding Path=Visual, RelativeSource={RelativeSource Self}, Converter={StaticResource FrameworkElementConverter}}">
                            <VisualBrush.Visual>
                                <Border CornerRadius="2" Background="White"
                                  Width="{Binding ActualWidth, ElementName=itemOuterGrid, TargetNullValue={x:Static System:Double.NaN}, FallbackValue={x:Static System:Double.NaN}}"
                                  Height="{Binding ActualHeight, ElementName=itemOuterGrid, TargetNullValue={x:Static System:Double.NaN}, FallbackValue={x:Static System:Double.NaN}}"/>
                            </VisualBrush.Visual>
                          </VisualBrush>
                        </Grid.OpacityMask>
                        <!-- Content i.e. the item itself (normally defined by the DataTemplate) -->
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        <!-- Inner Border with Checkmark -->
                        <Grid Name="SelectionMarker" Width="{Binding ActualWidth, ElementName=itemOuterGrid}" Height="{Binding ActualHeight, ElementName=itemOuterGrid}" Visibility="Collapsed">
                            <Border x:Name="OuterBorder" BorderThickness="4" BorderBrush="{TemplateBinding BorderBrush}" Margin="{TemplateBinding Padding}"/>
                            <Grid VerticalAlignment="Top" HorizontalAlignment="Right" Margin="{TemplateBinding Padding}">
                                <!-- Triangle -->
                                <Path Fill="{TemplateBinding BorderBrush}" Data="m 0 0 31 0 0 31 z" />
                                <!-- Check Mark -->
                                <Path Fill="{DynamicResource SecondaryAccentForegroundBrush}" Data="m 17 12 2 -2 3 3 6 -8 2 2 -8 10 z" Margin="-2"/>
                            </Grid>
                        </Grid>
                    </Grid>
                  </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="shadowBorder" Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
                            <Setter TargetName="shadowBorder" Property="wpf:ShadowAssist.Darken" Value="True"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="SelectionMarker" Property="Visibility" Value="Visible" />
                            <Setter TargetName="shadowBorder" Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
                            <Setter TargetName="shadowBorder" Property="wpf:ShadowAssist.Darken" Value="True"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="{DynamicResource DisabledOpacity}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="TileListBoxItemNoBorderStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}, FallbackValue=Stretch}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}, FallbackValue=Center}"/>
        <Setter Property="Margin" Value="4,0,4,8"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid Background="{TemplateBinding Background}" x:Name="itemOuterGrid" Margin="{TemplateBinding Margin}" wpf:ShadowAssist.ShadowDepth="Depth1" Effect="{Binding RelativeSource={RelativeSource Self}, Path=(wpf:ShadowAssist.ShadowDepth), Converter={x:Static converters:ShadowConverter.Instance}}">
                        <Grid.OpacityMask>
                            <VisualBrush>
                                <VisualBrush.Visual>
                                    <Border CornerRadius="2" Background="White"
                                      Width="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType={x:Type Grid}}, TargetNullValue={x:Static System:Double.NaN}, FallbackValue={x:Static System:Double.NaN}}"
                                      Height="{Binding ActualHeight, RelativeSource={RelativeSource AncestorType={x:Type Grid}}, TargetNullValue={x:Static System:Double.NaN}, FallbackValue={x:Static System:Double.NaN}}"/>
                                </VisualBrush.Visual>
                            </VisualBrush>
                        </Grid.OpacityMask>

                        <!-- Content i.e. the item itself (normally defined by the DataTemplate) -->
                        <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Grid>

                    <ControlTemplate.Triggers>
                        <!-- We use a nice animation on mouse over to fade the outer boder in/out -->
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="itemOuterGrid" Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
                            <Setter TargetName="itemOuterGrid" Property="wpf:ShadowAssist.Darken" Value="True"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="itemOuterGrid" Property="wpf:ShadowAssist.ShadowDepth" Value="Depth2"/>
                            <Setter TargetName="itemOuterGrid" Property="wpf:ShadowAssist.Darken" Value="True"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="{DynamicResource DisabledOpacity}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="ColorPickerTileListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderBrush" Value="{DynamicResource BrandBrush2}"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Grid Background="{TemplateBinding Background}" Margin="2">
                        <ContentPresenter Margin="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        <Border x:Name="OuterBorder" Opacity="0" BorderBrush="{DynamicResource ToothWorkParams.MaterialShadeMouseOverOutline}" BorderThickness="3"/>
                        <Grid Name="SelectionMarker" Visibility="Collapsed">
                            <Border BorderThickness="3" BorderBrush="{TemplateBinding BorderBrush}"/>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="Opacity" To="1" Duration="0:00:0.1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <DoubleAnimation Storyboard.TargetName="OuterBorder" Storyboard.TargetProperty="Opacity" To="0" Duration="0:00:0.1" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="true">
                            <Setter TargetName="SelectionMarker" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Opacity" Value="{DynamicResource DisabledOpacity}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>
